<!DOCTYPE html>
<title>Tests the timestamps provided to requestAnimationFrame callbacks</title>
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>

<script>
  async_test(t => {
    function busyWait(millis) {
      var start = Date.now();
      while (Date.now() - start < millis) { }
    }

    var firstTimestamp;

    window.requestAnimationFrame(function(timestamp) {
      firstTimestamp = timestamp;
      t.step(function() {
        assert_true(!!firstTimestamp);
      });
      busyWait(10);
    });

    var secondTimestamp;
    window.requestAnimationFrame(function(timestamp) {
      secondTimestamp = timestamp;
      t.step(function() {
        assert_true(!!secondTimestamp);
        assert_equals(firstTimestamp, secondTimestamp);
      });
    });

    requestAnimationFrame(function() {
      t.step(function() {
        assert_true(!!firstTimestamp);
      });
      t.done();
    });
  }, "Test the timestamps provided to rAF callbacks");
</script>
